﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using Zvezda.FSO2.DB;

namespace FSO.Reports
{
    /// <summary>
    /// Компонент для отображения параметров отчета "Полученные средства"
    /// </summary>
    public partial class UserControlRecievedMeansParams : UserControl, IReportParamList
    {
        public UserControlRecievedMeansParams()
        {
            InitializeComponent();
        }

        #region IReportParamList Members

        public Microsoft.Reporting.WinForms.ReportParameter[] Parameters
        {
            get 
            {
                List<ReportParameter> _listParams = new List<ReportParameter>(5);

                _listParams.Add(new ReportParameter("p_date_from", userControlDatePeriodSelector1.DateFrom.ToShortDateString(), false));

                _listParams.Add(new ReportParameter("p_date_to", userControlDatePeriodSelector1.DateTo.ToShortDateString(), false));

                string sTypeOfActivityValue = null;
                string sTypeOfActivityText = null;
                if (!userControlTypeOfActivitySelector1.IsNull)
                {
                    sTypeOfActivityValue = userControlTypeOfActivitySelector1.SelectedValue;
                    sTypeOfActivityText = userControlTypeOfActivitySelector1.SelectedText;
                }
                _listParams.Add(new ReportParameter("p_type_of_activity", sTypeOfActivityValue, false));
                _listParams.Add(new ReportParameter("v_nsi_type_of_activity", sTypeOfActivityText, false));

                string sContractValue = null;
                string sContractNumber = null;
                if (!userControlContractSelector1.IsNull)
                {
                    sContractValue = userControlContractSelector1.SelectedRow.ID.ToString();
                    sContractNumber = userControlContractSelector1.SelectedRow.NUMBER;
                }
                _listParams.Add(new ReportParameter("p_contract_id", sContractValue, false));
                _listParams.Add(new ReportParameter("v_contract_number", sContractNumber, false));

                string sNsiOrganization = null;
                string sNsiOrganiztionName = null;
                if (!userControlOrganizationSelector1.IsNull)
                {
                    sNsiOrganization = userControlOrganizationSelector1.SelectedRow.ID.ToString();
                    sNsiOrganiztionName = userControlOrganizationSelector1.SelectedRow.SHORT_NAME;
                }
                _listParams.Add(new ReportParameter("p_organization_id", sNsiOrganization, false));
                _listParams.Add(new ReportParameter("v_organization", sNsiOrganiztionName, false));

                string sSumFrom = null;
                string sSumTo = null;
                if (!userControlSelectSum1.IsNull)
                {
                    sSumFrom = userControlSelectSum1.FromSum.ToString();
                    sSumTo = userControlSelectSum1.ToSum.ToString();
                }
                _listParams.Add(new ReportParameter("p_sum_from", sSumFrom, false));
                _listParams.Add(new ReportParameter("p_sum_to", sSumTo, false));

                return _listParams.ToArray();
            }
        }

        #endregion

        /// <summary>
        /// Загружает данные из БД
        /// </summary>
        private void UserControlRecievedMeansParams_Load(object sender, EventArgs e)
        {
        }
    }
}
